import 'dart:convert';

import 'package:flutter/foundation.dart';


class PrintUtils{
  static print1(String tag,  message){
    try{
      if(message is !String){
        message =json.encode(message);
      }
        p( tag.trim()+": "+message);
    }catch(e){
      p(tag +e.toString());
    }
  }
  static print2(   message){
      p(message);
  }

  /// 信息太长,分段打印
  static void p(String msg) {
    if(kReleaseMode)return;
    //因为String的length是字符数量不是字节数量所以为了防止中文字符过多，
    //  把4*1024的MAX字节打印长度改为1000字符数
    int maxStrLength = 900;
    //大于1000时
    while (msg.length > maxStrLength) {
      debugPrint(msg.substring(0, maxStrLength));
      msg = msg.substring(maxStrLength);
    }
    //剩余部分
    debugPrint(msg);
  }
}